#include <stdio.h>
#include <unistd.h>
#include <poll.h>

int main()
{
    struct pollfd pf;
    pf.fd = 0;
    pf.events = POLLIN;
    while(1)
    {
        int ret = poll(&pf,1,1);
        if(ret < 0)
        {
            perror("poll");
            return 0;
        }
        else if(ret == 0)
        {
            printf("timeout\n");
            sleep(1);
            continue;
        }
        char buf[1024] = {0};
        read(0,buf,sizeof(buf)-1);
        printf("%s",buf);

    }
    return 0;
}
